# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=conscan
pkgver=1.2
pkgrel=5
groups=('blackarch' 'blackarch-fuzzer' 'blackarch-scanner' 'blackarch-webapp')
pkgdesc='A blackbox vulnerability scanner for the Concre5 CMS.'
arch=('any')
url='http://nullsecurity.net/tools/scanner.html'
depends=('python2' 'python2-wget' 'python2-lxml')
license=('custom:unknown')
source=("https://github.com/nullsecuritynet/tools/raw/main/scanner/$pkgname/release/$pkgname-$pkgver.tgz")
sha512sums=('07cf8e308bfe93a9d648a30e992cc912554c042c0ded5c15f332da7842c4082ec51daf44286d02eff509a23b6d5c51010b0bfbfcfe0f1bcaf08e77613ab84f58')

prepare() {
  sed -i 's|/bin/python|/bin/python2|' "$pkgname.py"
}

package() {
  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -R --no-preserve=ownership data modules "$pkgdir/usr/share/$pkgname"

  chmod -R 644 "$pkgdir/usr/share/$pkgname"
  chmod -R a+X "$pkgdir/usr/share/$pkgname"

  install -m 755 "$pkgname.py" "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

